<template>
  <el-dialog :title="!dataForm.id ? '新建管理区域配置' : isDetail ? '详情' : '编辑管理区域配置'" :close-on-click-modal="false" :visible.sync="visible" class="cu-dialog cu-dialog_center" lock-scroll width="800px">
    <el-form ref="elForm" :model="dataForm" size="small" label-width="120px" label-position="right" :disabled="!!isDetail" :rules="rules">
      <el-row :gutter="15" type="flex" style="flex-wrap:wrap">
        <el-col :span="12">
          <el-form-item label="管理区域" prop="areaCode">
            <el-select v-model="dataForm.areaCode" placeholder="请选择管理区域" filterable clearable required :style="{ width: '100%' }" @change="handleAreaChange">
              <el-option v-for="item in areaOptions" :key="item.enCode" :label="item.fullName" :value="item.enCode"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="省份" prop="provinceId">
            <el-select v-model="dataForm.provinceId" placeholder="请选择省份" filterable clearable required :style="{ width: '100%' }" @change="handleProvinceChange">
              <el-option v-for="item in provinceOptions" :key="item.id" :label="item.fullName" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="城市" prop="cityId">
            <el-select v-model="dataForm.cityId" placeholder="请选择城市（可选）" filterable clearable :style="{ width: '100%' }" @change="handleCityChange">
              <el-option label="整个省份" :value="null"></el-option>
              <el-option v-for="item in cityOptions" :key="item.id" :label="item.fullName" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="优先级" prop="priority">
            <el-input-number v-model="dataForm.priority" :min="0" :max="100" placeholder="请输入优先级" :style="{ width: '100%' }" />
            <div class="form-tip">数字越大优先级越高，用于处理重叠管辖范围</div>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="状态" prop="enabledMark">
            <el-radio-group v-model="dataForm.enabledMark">
              <el-radio :label="1">启用</el-radio>
              <el-radio :label="0">禁用</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="排序码" prop="sortCode">
            <el-input-number v-model="dataForm.sortCode" :min="0" placeholder="请输入排序码" :style="{ width: '100%' }" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="描述" prop="description">
            <el-input v-model="dataForm.description" placeholder="请输入描述信息" show-word-limit maxlength="500" :style="{ width: '100%' }" type="textarea" :autosize="{ minRows: 3, maxRows: 5 }"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" @click="dataFormSubmit()" v-if="!isDetail">确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
export { default } from './index.js'
</script>
<style lang="scss" scoped>
.form-tip {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
  line-height: 1.2;
}

.el-form-item {
  margin-bottom: 20px;
}

.dialog-footer {
  text-align: right;
  
  .el-button {
    margin-left: 10px;
  }
}
</style>